//
//  HeaderReusableView.m
//  MindBox
//
//  Created by MS on 16-1-5.
//  Copyright (c) 2016年 Lemon. All rights reserved.
//

#import "HeaderReusableView.h"

@interface HeaderReusableView ()

@property (nonatomic,weak) UILabel * lab;

@end

@implementation HeaderReusableView

-(UILabel *)lab
{
    if (_lab==nil) {
        UILabel * lab = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, self.frame.size.width-20, self.frame.size.height)];
        lab.font = [UIFont systemFontOfSize:12];
        lab.textColor = [UIColor colorWithRed:0.42f green:0.42f blue:0.42f alpha:1.00f];
        _lab = lab;
        [self addSubview:lab];
    }
    return _lab;
}

-(void)setName:(NSString *)name
{
    _name = name;
    
    self.lab.text = name;
}

+(instancetype)headerReusableViewWithCollectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    NSString * className = NSStringFromClass([self class]);
    [collectionView registerClass:[self class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:className];
    
    HeaderReusableView * view =nil;
    if (kind==UICollectionElementKindSectionHeader) {
         view = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:className forIndexPath:indexPath ];
    }
    return  view;
}

@end
